package test;
import java.util.Arrays;
import java.util.Scanner;
public class Extra0218 {
    public static void main(String[] args) {
        int n = 0;
        int []arr=new int[1];
        for(;;) {
            first();
            Scanner scan = new Scanner(System.in);
            int m = scan.nextInt();
            n = n + choose(m);//计算总价
            if(m<7){arr=Arrays.copyOf(arr,arr.length+1);//扩容
            arr[arr.length-2]=m;}//给倒数第二位赋值
            if (m == 5) {
                second(m, n);//结算
                break;
            }
            else if (m==6){
                break;//退出
            }
            else if (m==7){//查看购物车
                arr=Arrays.copyOf(arr,arr.length-1);
                System.out.print("当前购物车为：");
                for(int i=0;i<arr.length;i++){
                    System.out.print(arr[i]+" ");
                }
                System.out.println();
            }
        }
        }
    public static void first() {//选择界面
        System.out.println("请选择商品 1.可乐 2.雪碧 3.红牛 4.果粒橙 5.结算 6.退出 7.查看购物车 ");
    }
    public static void second(int a,int b){//结算
            if(a==5){
                if(b<=10){
                    System.out.println("总金额为："+b*0.9);
                }//不满十块打九折
                else if(b<=20){
                    System.out.println("总金额为："+b*0.8);
                }//满10打8折
                else if(b<=30){
                    System.out.println("总金额为："+b*0.7);
                }//满20打7折
                else if(b<=40){
                    System.out.println("总金额为："+b*0.6);
                }//满30打6折
                else {
                    System.out.println("总金额为："+b*0.5);
                }//满40打5折
            }
            }
    public static int choose(int num){//选择商品，计算总价
        int sum =0;
        switch(num){
            case 1:
                sum+=3;
                break;
            case 2:
                sum+=4;
                break;
            case 3:
                sum+=10;
                break;
            case 4:
                sum+=5;
                break;
            case 5:
                break;
        }
        return sum;
    }
}
